<template>
  <view class="container">
    <uni-nav-bar
      :border="false"
      statusBar
      title="邀约详情"
      color="#000"
      left-icon="left"
      backgroundColor="transparent"
      @clickLeft="onBack"
    >
    </uni-nav-bar>

    <view class="box">
      <view class="mainBox">
        <view class="id">受访人员: {{ data?.entourageUserId }}</view>
        <!-- <view class="val">{{ $util.selectDictLabel(allocateData, data?.status) }}</view> -->
        <view class="status"
          >状态: {{ $util.selectDictLabel(status, data?.status) }}</view
        >
      </view>
      <view class="infoBox">
        <view class="item">
          <text class="name">申请人</text>
          <text class="val">{{ data?.applicationUser }}</text>
        </view>
        <view class="item" v-if="data?.deptName">
          <text class="name">所在部门</text>
          <text class="val">{{ data?.deptName }}</text>
        </view>
        <view class="item" v-if="data?.applicationPhone">
          <text class="name">申请人电话</text>
          <text class="val">{{ data?.applicationPhone }}</text>
        </view>
        <view class="item">
          <text class="name">申请时间</text>
          <text class="val">{{ data?.applicationDate }}</text>
        </view>
        <view class="item">
          <text class="name">访客姓名</text>
          <text class="val">{{ data?.visitorName }}</text>
        </view>
        <view class="item">
          <text class="name">访客单位</text>
          <text class="val">{{ data?.visitorUnit }}</text>
        </view>
        <view class="item">
          <text class="name">访客电话</text>
          <text class="val">{{ data?.visitorPhone }}</text>
        </view>
        <view class="item">
          <text class="name">来访事由</text>
          <text class="val">{{ data?.visitReason }}</text>
        </view>
        <view class="item">
          <text class="name">来访前地址</text>
          <text class="val">{{ data?.address }}</text>
        </view>
        <view class="item">
          <text class="name">访客身体状况</text>
          <text class="val">{{ data?.visitorPhysicalCondition }}</text>
        </view>
        <view class="item">
          <text class="name">来访方式</text>
          <text class="val">{{
            $util.selectDictLabel(visitWay, data.visitWay)
          }}</text>
        </view>
        <view class="item">
          <text class="name">来访时间</text>
          <text class="val">{{ data?.visitTime }}</text>
        </view>
        <view class="item">
          <text class="name">离矿时间</text>
          <text class="val">{{ data?.leaveTime }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import _ from 'lodash';
import { getDictList, getUserAllList } from '@/api/index';
import { getVisitorInviteDetail } from '@/api/workflow';
import useAppStore from '@/store/modules/app';
export default {
  components: {},
  data() {
    return {
      visitWay: [
        {
          text: '驾车',
          label: '驾车',
          value: '1',
        },
        {
          text: '出租车/网约车',
          label: '出租车/网约车',
          value: '2',
        },
        {
          text: '步行',
          label: '步行',
          value: '3',
        },
        {
          text: '骑行',
          label: '骑行',
          value: '4',
        },
      ],
      data: {},
      query: {},
      status: [],
      userData: [],
      // store
      appStore: useAppStore(),
    };
  },
  onLoad(query) {
    // if (query) {
    //   // 解码
    //   // let path = decodeURIComponent(query);
    //   let path = query;
    //   // 取url路径参数
    //   const params = _.split(path, '?');
    //   let formattedParams = _.chain(params[params.length - 1])
    //     .split('&')
    //     .map(_.ary(_.partial(_.split, _, '='), 1))
    //     .fromPairs()
    //     .value();
    //   this.query = formattedParams;
    // }
    if (Object.keys(query).length) {
      // 解码
      this.query = query;
    }
    this.init();
    this.getData();
  },
  methods: {
    init() {
      getDictList('wf_business_status').then((res) => {
        this.status = res.data.map((item) => {
          return {
            ...item,
            text: item.dictLabel,
            label: item.dictLabel,
            value: item.dictValue,
          };
        });
      });
    },
    getData() {
      getVisitorInviteDetail(this.query.id).then((res) => {
        this.data = {
          ...res.data,
          entourageUserId: '',
        };
        // 获取姓名
        getUserAllList({ userId: res.data.entourageUserId }).then((res) => {
          this.data.entourageUserId = res.data[0].nickName;
        });
      });
    },
    // 跳转页面
    onLocation(url) {
      uni.navigateTo({
        url,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  min-height: calc(100vh - 160rpx);
  padding-bottom: calc(
    var(--window-bottom) + constant(safe-area-inset-bottom) + 160rpx
  );
  padding-bottom: calc(
    var(--window-bottom) + env(safe-area-inset-bottom) + 160rpx
  );
  background: linear-gradient(180deg, #d7e4fd 0%, #fff 50%);
  background-repeat: no-repeat;
  background-size: 100% auto;
  position: relative;
  .box {
    margin: 50rpx 36rpx 0;
    padding: 24rpx;
    background: #ffffff;
    border-radius: 12rpx;
    box-shadow: 0 0 30rpx 0 #ccc;
    .mainBox {
      text-align: center;
      padding: 40rpx 0;
      line-height: 1;

      .id {
        font-size: 38rpx;
        font-weight: bold;
        color: #4288ff;
        padding-bottom: 40rpx;
      }

      .val {
        font-size: 40rpx;
        font-weight: 800;
        color: #ff884d;
        padding-bottom: 27rpx;

        text {
          font-size: 30rpx;
          margin-left: 10rpx;
        }
      }

      .status {
        font-size: 26rpx;
        font-weight: 500;
        color: #555555;
      }
    }
    .infoBox {
      .item {
        font-size: 30rpx;
        font-weight: 500;
        padding: 22rpx 12rpx;
        display: flex;
        justify-content: space-between;
        border-bottom: 2rpx solid #eaeaea;
        &:last-child {
          border-bottom: 0;
        }
        .name {
          color: #989898;
        }

        .val {
          width: 60%;
          color: #333;
          text-align: right;
          word-break: break-all;
        }
      }
    }
  }
  .myLabel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .star {
      color: #dd524d;
    }
  }
  .footer {
    display: flex;
    justify-content: space-evenly;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(
      var(--window-bottom) + constant(safe-area-inset-bottom) + 60rpx
    );
    bottom: calc(var(--window-bottom) + env(safe-area-inset-bottom) + 60rpx);
    .btn {
      width: 40%;
      margin: 0;
    }
  }
  .btnBox {
    margin: 60rpx 0 10rpx;
    .btn {
      background: linear-gradient(
          to bottom,
          #d5dee7 0%,
          #e8ebf2 50%,
          #e2e7ed 100%
        ),
        linear-gradient(
          to bottom,
          rgba(0, 0, 0, 0.02) 50%,
          rgba(255, 255, 255, 0.02) 61%,
          rgba(0, 0, 0, 0.02) 73%
        ),
        linear-gradient(
          33deg,
          rgba(255, 255, 255, 0.2) 0%,
          rgba(0, 0, 0, 0.2) 100%
        );
      background-blend-mode: normal, color-burn;
    }
  }
}
</style>
